<template>
	<view class="indexs">
		<view class="header header_wi" :style="'padding-top: ' + navH + 'px;'">
			<view class="header_height" :style="'height:' + gaodu + 'px;line-height:' + gaodu + 'px;top:' + gaodutops + 'px;'">
				<view class="index_h_cont3">
					<view class="index_wenben_img" @tap="jumpzuo"><image :src="imgUrl + '/dzx_img33.png'" mode="widthFix"></image></view>
					<view class="index_wenben">{{ $t('page_dizhi.pickup_address_yet') }}</view>
				</view>
			</view>
			<view class="coloe_title">s</view>
		</view>
		<view class="index_center" :style="'padding-top:' + (navH + 50) + 'px;padding-bottom:130rpx;'">
			<view class="dizhi_center">
				<view class="dizhi_item1">
					<view class="dizhi_item1_list" v-if="arrlist.length != 0">
						<view class="dizhi_item1_cont" @tap="xuanze" :data-id="item.address_id" v-for="(item, index) in arrlist" :key="index">
							<view class="dizhi_item1_cont_t">
								<view class="dizhi_item1_cont_l">
									<view class="dizhi_item1_cont_t1">{{ item.name }} {{ item.phone }}</view>
									<view class="dizhi_item1_cont_t2">
										{{ item.country }}{{ item.province }}{{ item.city }}{{ item.district }}{{ item.detail }} {{ item.door }}
									</view>
								</view>
								<view class="dizhi_item1_cont_r">
									<view class="dizhi_item1_cont_r_btns" @tap.stop.prevent="bianji" :data-id="item.address_id">
										<text>{{ $t('page_dizhi.choose') }}</text>
									</view>
								</view>
							</view>
						</view>
					</view>
					<view class="dizhi_item1_kong" v-else>
						<image :src="imgUrl + '/dzx_img80.png'"></image>
						<text>{{ $t('page_dizhi.No_pickup_address_yet') }}</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
// pages/shouye/shouye_zkc/shouye_zkc.js
const app = getApp();

let request = require('../../../utils/require');

export default {
	data() {
		return {
			navH: app.globalData.navHeight,
			gaodu: app.globalData.height,
			gaodutops: app.globalData.top,
			imgUrl: app.globalData.imgUrl,
			arrlist: [],
			type: '',
			address_id: '',
			ischoose: 1
		};
	},
	/**
	 * 生命周期函数--监听页面加载
	 */ onLoad(options) {
		var that = this;
		that.type= options.type
	},
	onShow() {
		var that = this;
		that.dizhilist();
	},
	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady: function() {},
	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide: function() {},
	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload: function() {},
	/**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
	onPullDownRefresh: function() {},
	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom: function() {},
	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage: function() {},
	methods: {
		dizhilist() {
			var that = this;
			var data = {
				token: uni.getStorageSync('token')
			};
			request.post(`index.php?s=/api/address/dslists&wxapp_id=` + uni.getStorageSync('web_id'), data).then(res => {
				console.log(res.data.data.list, 8867);
				if (res.data.code == 1) {
					that.arrlist= res.data.data.list
				}
			});
		},

		jumpzuo() {
			uni.navigateBack();
		},

		xuanze(e) {
			// #ifdef MP-WEIXIN
			if (this.type == 'xuanze') {
				var pages = getCurrentPages();
				var prevPage = pages[pages.length - 2];
			
				prevPage.data.address_id= e.currentTarget.dataset.id
				prevPage.data.ischoose= 2
				uni.navigateBack({
					delta: 1
				});
			}
			// #endif
			// #ifdef H5
			if (this.type == 'xuanze') {
				var pages = getCurrentPages();
				var prevPage = pages[pages.length - 2]
				prevPage.address_id= e.currentTarget.dataset.id
				prevPage.ischoose= 2
				uni.navigateBack({
					delta: 1
				});
			}
			// #endif
		}
	}
};
</script>
<style>
@import './dizhi.css';
</style>
